@echo off
rem --- START --------------------------------------------------------
:start
echo Executing: %0 ...
rem if "%PDRV%"   == "" goto errmsg
rem if "%PDIR%"   == "" goto errmsg
rem if "%PHOME%"  == "" goto errmsg
rem if "%ERRLOG%" == "" goto errmsg

goto go_on
:errmsg
echo.
echo autoexec.bat: Erforderliches Environment fehlerhaft:
echo.
echo set PDRV=(project-drive)      z.B. C
echo set PDIR=(project-directory)  z.B. Tequila\Projects
echo set PHOME=(project-drive):\(project-directory)
echo set ERRLOG=(project-drive):\(project-directory)\error.log
echo.

goto done
:go_on

rem ------------------------------------------------------------------

:main
if exist .\out\*.sql del .\out\*.sql

if .%1==. goto mess
if .%2==. goto mess
if exist %2.lst del %2.lst >nul
if exist buildlst.bat del buildlst.bat >nul

echo # %1 %2 %3 >stplst.tmp 
dir /b %1\*.sql >>stplst.tmp 

stpbuild\stpbuild stplst.tmp

if exist %2.sql del %2.sql >nul
call %2.bat %2.sql >nul

@echo off
goto done

:mess
rem --- Missing input ---------------------------------------------------------
echo stpb need at least two params
echo stpbin_subdir_name out_script_file (both without extension) [triggers]
rem --- Missing input ---------------------------------------------------------


rem --- DONE ---------------------------------------------------------
:done
if exist %2.bat del %2.bat >nul
if exist %2.lst del %2.lst >nul
if exist %1.lst del %1.lst >nul
if exist stplst.tmp del stplst.tmp >nul
echo.
rem ------------------------------------------------------------------
